https://introtcs.org/public/lec_03_computation.html
๊ฐ์
The main takeaways from this chapter are:
-
We can use logical operations such as AND, OR, and NOT to compute an output from an input (see Section 3.2).
-
A Boolean circuit is a way to compose the basic logical operations to compute a more complex function (see Section 3.3). We can think of Boolean circuits as both a mathematical model (which is based on directed acyclic graphs) as well as physical devices we can construct in the real world in a variety of ways, including not just silicon-based semi-conductors but also mechanical and even biological mechanisms (see Section 3.5).
-
We can describe Boolean circuits also as straight-line programs, which are programs that do not have any looping constructs (i.e., no
while
/for
/do .. until
etc.), see Section 3.4. -
It is possible to implement the AND, OR, and NOT operations using the NAND operation (as well as vice versa). This means that circuits with AND/OR/NOT gates can compute the same functions (i.e., are equivalent in power) to circuits with NAND gates, and we can use either model to describe computation based on our convenience, see Section 3.6. To give out a โspoilerโ, we will see in Chapter 4 that such circuits can compute all finite functions.
One โbig ideaโ of this chapter is the notion of equivalence between models (Big Idea 3). Two computational models are equivalent if they can compute the same set of functions. Boolean circuits with AND/OR/NOT gates are equivalent to circuits with NAND gates, but this is just one example of the more general phenomenon that we will see many times in this book.
์ด๋ฒ ์ฅ์์๋ ๋ค์๊ณผ ๊ฐ์ ๋ด์ฉ์ ๊ณต๋ถํ๋ค๊ณ ํ๋ค.
- ๋ ผ๋ฆฌ ์ฐ์ฐ AND, OR, NOT์ ์ฌ์ฉํด ์ ๋ ฅ์ ๋ํด ์ถ๋ ฅ์ ๋ด๋๋ ๋ฐฉ๋ฒ.
- ๋ถ์ธ ํ๋ก๋ ๊ธฐ๋ณธ์ ์ธ ๋ ผ๋ฆฌ ์ฐ์ฐ์ ์กฐํฉํด ๋ณต์กํ ํจ์๋ฅผ ๋ง๋๋ ๊ฒ์ด๋ค.
- ๋ถ์ธ ํ๋ก๋ฅผ straight-line ํ๋ก๊ทธ๋จ(๋ฐ๋ณต๋ฌธ์ด ์๋ ์ฝ๋)์ผ๋ก ์์ฑํ๋ค.
- AND, OR, NOT์ ์กฐํฉํด NAND๋ฅผ ๋ง๋ค ์ ์๊ณ ๋ฐ๋๋ก๋ ํ ์ ์๋ค.
Defining Computation
"์๊ณ ๋ฆฌ์ฆ"์ด๋?
informal : An algorithm is a set of instructions for how to compute an output from an input by following a sequence of "elementary steps".
An algorithm computes a function if for every input x, if we follow the instructions of A on the input , we obtain the output .
์ ํด์ง ๋ฐฉ๋ฒ๊ณผ ์์๋๋ก ๋จ๊ณ๋ค์ ๋ฐ์๊ฐ๋ฉด์ ์
๋ ฅ๋ ๊ฐ์ ๋ฐ๋ผ ์ถ๋ ฅ๊ฐ์ ๋ด๋๋ ์ผ๋ จ์ ์ง์นจ๋ค์ด๋ค.
AND, OR, NOT
OR(a,b) :
- 0 : a=b=0 ์ผ ๋
- 1 : ๋๋จธ์ง ๊ฒฝ์ฐ
AND(a,b) : - 1 : a=b=1 ์ผ ๋
- 0 : ๋๋จธ์ง ๊ฒฝ์ฐ
NOT(a) : - 1 : a = 0
- 0 : a = 1
a && (b || c) = (a && b) || (a && c) ์ผ๊น?
์ฐธ์ ์์, ๊ฑฐ์ง์ 0์ผ๋ก ํ๊ณ AND๋ * OR๋ + ๋ผ๊ณ ํด๋ณด์.
์ํ์์ ๋ถ๋ฐฐ์ ๋ฒ์น์ ๋ฐ๋ผa*(b+c) = ab + ac
๊ฐ ๋๋ค.
XOR
XOR(a,b) : a+b mod 2
- 0 : a ์ b ๋ชจ๋ ์ฐธ์ด๊ฑฐ๋, ๋ชจ๋ ๊ฑฐ์ง์ผ ๋
- 1: ํ๋๊ฐ ์ฐธ์ด๊ณ ํ๋๊ฐ ๊ฑฐ์ง์ผ ๋
XOR๋ฅผ AND, OR, NOT์ผ๋ก ๊ตฌํํ๋ ค๋ฉด?
w1 = AND(a,b)
w2 = NOT(w1)
w3 = OR(a,b)
AND(w2,w3)